
import LanguageMng from "../../Managers/LanguageMng";

cc.Class({
    extends: cc.Component,

    properties: {
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
    },

    start () {

    },

    // update (dt) {},

    onMenuHowToPlayClicked:function (event) {
        let btnName = event.target.name
        if(btnName === "tutorial"){
            cc.gg.tdUtil.doSendTdEvent("click_menu_howtoplay_tutorial","HowToPlay")
            cc.gg.dataMgr.playGuild = true
            cc.director.loadScene('TwoPlayerGame')
        }else if(btnName === "help"){
            // cc.find("Canvas/GameMenu/MenuBlockBg").active = true

            cc.gg.tdUtil.doSendTdEvent("click_menu_howtoplay_help","HowToPlay")
            cc.loader.loadRes("windows/MoreHelp",cc.Prefab,function (err, prefab) {
                let newNode = cc.instantiate(prefab)
                newNode.width = cc.winSize.width
                newNode.height = cc.winSize.height

                let infoNode = cc.find("Canvas/Windows")
                infoNode.addChild(newNode)
                this.windowEnterFromTop(newNode)

                newNode.getComponent("MoreHelp").setMoreHelpCloseFunc(function () {
                    this.windowOutToBottomAndDestroy(newNode)

                    cc.loader.releaseRes("windows/MoreHelp")
                }.bind(this))
            }.bind(this))
        }
    },


    windowOutToBottomAndDestroy:function (node) {
        node.active = true
        node.x = 0
        let seq = cc.sequence(cc.moveTo(0.12,0,-cc.winSize.height/2),
            cc.callFunc(function () {
                this.destroy()
            }.bind(node),this))
        node.runAction(seq)
    },

    windowEnterFromTop:function (node) {
        node.stopAllActions()
        node.active = true
        node.x = 0
        node.y = cc.winSize.height/2 + node.height
        node.runAction(cc.moveBy(0.12,0,-cc.winSize.height/2-node.height/2))
    },
});
